<template>
    <div class="cms-message">
        <div class="cms-message-content">

            <div class="message-title">联系我们</div>
            <hr class="message-hr"/>
    
            <div class="link-box">
                <div class="link-box-con">
                    <div class="link-box-icon"><img src="@/assets/images/phone.png"></div>
                    <div class="link-box-text">电话</div>
                    <div class="link-box-content">求职找工作：{{office.chargePhone}}</div>
                </div>
            </div>

            <div class="link-box">
                <div class="link-box-con">
                    <div class="link-box-icon"><img src="@/assets/images/email.png"></div>
                    <div class="link-box-text">邮箱</div>
                    <div class="link-box-content">求职找工作：{{office.chargeEmail}}</div>
                </div>
            </div>

            <div class="link-box">
                <div class="link-box-con">
                    <div class="link-box-icon"><img src="@/assets/images/address.png"></div>
                    <div class="link-box-text">地址</div>
                    <div class="link-box-content">求职找工作：{{office.officeAddress}}</div>
                </div>
            </div>

            <div class="message-box">
                <textarea class="message-text" cols="100" rows="4" v-model="message.messageContent"></textarea>
                <div class="message-right">
                    <input type="text" placeholder="姓名" class="form-name" v-model="message.userName">
                    <input type="tel" class="form-tels" placeholder="请输入手机号" v-model="message.userPhone">
                    <input type="email" placeholder="请输入邮箱" class="form-email" v-model="message.userEmail">
                    <div class="form-sub" @click="subMessage">提交</div>
                </div>
            </div>

        </div>
    </div>
</template>

<script>
    import messageApi from '@/api/messageApi'
    export default {
        name: "CmsMessage",
        data(){
            return{
                officeId:'0010a5ad4b4e1293bb005199c2c8cb31',
                office:{},
                message:{
                    messageContent:'留言内容',
                    userName:'',
                    userPhone:'',
                    userEmail:''
                }
            }
        },
        methods:{
            async subMessage(){
                let message = this.message;
                if (message.userName.trim()==''){
                    this.$message.warning("请输入您的姓名")
                }else if (message.userPhone.trim()==''){
                    this.$message.warning("请输入您的联系方式")
                }else if (message.userEmail.trim()==''){
                    this.$message.warning("请输入您的邮箱")
                }else if (message.messageContent.trim()==''){
                    this.$message.warning("请输入留言内容")
                }else {
                    let res = await messageApi.saveMessage(message);
                    if (res.code == '200'){
                        this.$message.success("留言成功！")
                    }else {
                        this.$message.error("留言失败！")
                    }
                }
            }
        },
        created:async function(){
            let res = await messageApi.getOffice(this.officeId);
            if (res.code=='200'){
                this.office = res.data
                console.log(res)
            }
        }

    }
</script>

<style scoped>
    .cms-message {
        width: 100%;
        height: auto;
        background-color: #FFFFFF;
        float: left;
    }
    .cms-message-content{
        width: 80%;
        margin-left: 10%;
        float: left;
        margin-bottom: 20px;
    }
    .message-title{
        margin-top: 15px;
        font-size: 32px;
        margin-bottom: 10px;
        color: #ff7908;
    }
    .message-hr{
        border-color: #ff7908;
        opacity: 0.4;
    }
    .link-box{
        margin-top:50px;
        width: 33.3%;
        float: left;
        height: 300px;
        min-height: 300px;
    }
    .link-box-con{
        height: 100%;
        width: 80%;
        margin-left: 10%;
        border: 1px black solid;
        text-align: center;
        min-height: 300px;
    }
    .link-box-icon{
        cursor: pointer;
        width: 50px;
        height: 50px;
        margin-top: 20%;
        margin-left: auto;
        margin-right: auto;
    }
    .link-box-icon > img{
        width: 100%;
        height: 100%;
        transition: all 0.6s;
    }
    .link-box-icon > img:hover{
        transform: scale(1.3);
    }
    .link-box-text{
        margin-top: 10px;
        font-size: 22px;
        border-bottom: 5px chocolate solid;
        width: 70px;
        margin-left: auto;
        margin-right: auto;
    }
    .link-box-content{
        font-size: 14px;
        margin-top: 10px;
    }
    .message-text{
        width: 100%;
        height: 120px;

    }
    .message-text{
        height: 200px;
        width: 50%;
        overflow: hidden;
        text-indent: 1rem;
        box-sizing: border-box;
        padding: 5px;
        border: 1px solid #CCCCCC;
        background-color: #FFFFFF;
        line-height: 26px;
        margin-top: 50px;
    }
    .message-right{
        height: 200px;
        width: 50%;
        float: right;
    }
    .message-right input{
        text-indent: 1rem;
        box-sizing: border-box;
        background-color: #FFFFFF;
        border: 1px solid #CCCCCC;
        padding: 5px 0;
        height: 35px;
    }
    .form-name,.form-email,.form-tels,.form-sub{
        margin-top: 20px;
        width: 90%;
        margin-left: 10%;
        float: left;
    }
    .form-name{
        margin-top: 50px;
    }
    .form-sub{
        height: 35px;
        line-height: 35px;
        text-align: center;
        cursor: pointer;
        color: #FFFFFF;
        font-size: 18px;
        background-color: #ff7908;
    }
</style>